<html>
<head></head>
<body>
<input type="submit" id="userCustomer" value="userCustomer">
<input type="submit" id="userVendor" value="userVendor">
<input type="submit" id="userManager" value="userManager">

<div>
    name:<br/>
    <input type="text" id="name" placeholder="name" value="root"><br/>
    pwd: <br/>
    <input type="text" id="pwd" placeholder="password" value="root"><br/>
    userType:customer/vendor/manager <br/>
    <input type="text" id="userType" placeholder="userType" value="customer"><br/>

    <input type="submit" id="register" value="register">
    <input type="submit" id="login" value="login">
</div>

</body>
<script src="/js/jquery.js"></script>
<script src="/js/index.js"></script>
<script>
    $('#userManager').on('click', function () {
        $('#name').val('root');
        $('#pwd').val('root');
    });
    $('#userVendor').on('click', function () {
        $('#name').val('vendor1');
        $('#pwd').val('vendor1');
    });
    $('#userCustomer').on('click', function () {
        $('#name').val('customer1');
        $('#pwd').val('customer1');
    });
</script>
<script>
    $('#register').on('click', function () {
        var name = $('#name').val();
        var pwd = $('#pwd').val();
        var userType = $('#userType').val();
        register(name, pwd, userType, function (err, data) {
            if (err) return console.log('err ', err);
            console.log(data);
        });
    });

    $('#login').on('click', function () {
        var name = $('#name').val();
        var pwd = $('#pwd').val();
        var userType = $('#userType').val();
        login(name, pwd, userType, function (err, data) {
            if (err) return console.log('err ', err);
            console.log(data);
            if (data.userType == 'customer')  window.location.href = "/customer/index.html";
            if (data.userType == 'manager')  window.location.href = "/manager/index.html";
            if (data.userType == 'vendor')  window.location.href = "/vendor/index.html";
        });
    });

</script>
</html>